typedef struct ListNode ListNode;
struct ListNode* partition(struct ListNode* head, int x)
{ 
    ListNode* prev = NULL;
    ListNode* pcur = head;
    ListNode* ptail, *newPtail, *phead;
    phead = ptail = newPtail = head;
    //判空
    if(head == NULL)
    { 
        return NULL;
    } 
    //先找尾，作为结束标注
    while(ptail->next)
    { 
        ptail = ptail->next;
    } 
    newPtail = ptail;
    //找返回的头
    //如何解决全是需要尾插的情况
    //如果全是尾插的情况，应该返回ptail；
    while((phead->next != NULL) && (phead->val >= x))
    {
        phead = phead->next;
    } 
    while(pcur != ptail)
    { 
        if(pcur->val < x)
        { 
            //不进行任何操作
            prev = pcur;
            pcur = pcur->next;
        } 
        else 
        { 
            //执行尾插
            if(prev != NULL)
            { 
                prev->next = pcur->next;
            } 
            newPtail->next = pcur;
            newPtail = newPtail->next;
            pcur = pcur->next;
        } 
    } 
    newPtail->next = NULL;
    return phead;
}